package com.srd.phone.activity;

import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;

import com.shengrongdai.srd.R;

/**
 * 自动投资
 */
public class AutoInvestActivity extends BaseActivity implements View.OnClickListener {

    private LinearLayout ll_layout;
    private CheckBox cb_swicher, et_check_box1, et_check_box2, et_check_box3;
    private Button btn_commit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_auto_invest);

        initView();
        initData();
    }

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    public void initView() {
        tv_common_title.setText("自动投资");

        cb_swicher = (CheckBox)findViewById(R.id.cb_swicher);
        cb_swicher.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    new AgreementDialog(AutoInvestActivity.this, new AgreementDialog.OnCallBack() {
                        @Override
                        public void onClick(boolean bool) {
                            if (bool) {
                                ll_layout.setVisibility(View.VISIBLE);
                                btn_commit.setVisibility(View.VISIBLE);
                                cb_swicher.setChecked(true);
                            } else {
                                ll_layout.setVisibility(View.GONE);
                                btn_commit.setVisibility(View.GONE);
                                cb_swicher.setChecked(false);
                            }
                        }
                    });
                } else {
                    ll_layout.setVisibility(View.GONE);
                }
            }
        });

        ll_layout = (LinearLayout)findViewById(R.id.ll_layout);
        ll_layout.setVisibility(View.GONE);


        et_check_box1 = (CheckBox)findViewById(R.id.et_check_box1);
        et_check_box1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked){
                    et_check_box2.setChecked(false);
                    et_check_box3.setChecked(false);
                }

            }
        });
        et_check_box2 = (CheckBox)findViewById(R.id.et_check_box2);

        et_check_box2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked) {
                    et_check_box1.setChecked(false);
                    et_check_box3.setChecked(false);
                }
            }
        });

        et_check_box3 = (CheckBox)findViewById(R.id.et_check_box3);

        et_check_box3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked) {
                    et_check_box1.setChecked(false);
                    et_check_box2.setChecked(false);
                }
            }
        });

        btn_commit = (Button)findViewById(R.id.btn_commit);
        btn_commit.setOnClickListener(this);
        btn_commit.setVisibility(View.GONE);

    }

    public void initData() {

    }

    @Override
    public void onClick(View v) {

        switch (v.getId()){
            case R.id.btn_commit:

                break;
        }

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

}